package com.springBoot.exception;

import java.util.Map;

import org.springframework.boot.web.servlet.error.DefaultErrorAttributes;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.WebRequest;

@Component
public class MyException extends DefaultErrorAttributes{
	
	@Override
	public Map<String, Object> getErrorAttributes(WebRequest webRequest, boolean includeStackTrace) {
		Map<String,Object> errorMap = super.getErrorAttributes(webRequest, includeStackTrace);
		errorMap.clear();
		errorMap.put("code", 500);
		errorMap.put("msg", "服务器出错");
		return errorMap;
	}
}
